<template >
  <div>
    <song-list-header :songListIntro="this.songListIntro" > </song-list-header>
    <v-scroll :enable-refresh="false" :enable-infinite="false" >
      <ul class="ul">
        <li><!--v-for="(item,index) in listdata"-->
          <div class="par-box" >
            <div class="background-img" :style="{backgroundImage:'url('+ backgroundUrl +')', 'background-size': '1000%', 'background-position' : 'center center'}">
            </div>
            <div class="list-intro">
              <div class="b-name">
                <img class="list-img" :src="backgroundUrl"><!--  ../../../static/image/test-header-backgourend.jpg   -->
                <div class="about">
                  <p>我喜欢的音乐</p>
                  <div class="_username">
                    <img class="user-img" src="http://img3.imgtn.bdimg.com/it/u=1646088349,1472429906&fm=27&gp=0.jpg"><!--  ../../../static/image/header-img.jpg   -->
                    <p>渔岛钟情 > </p>
                  </div>
                  <div></div>
                </div>
              </div>
              <div class="b-button">
                <div class="link-bu">
                  <i class="icon-add-project"></i>
                  <p>收藏</p>
                </div>
                <div>
                  <i class="icon-msg"></i>
                  <p>评论</p>
                </div>
                <div>
                  <i class="icon-SHARE2"></i>
                  <p>分享</p>
                </div>
                <div>
                  <i class="icon-download"></i>
                  <p>下载</p>
                </div>
              </div>
            </div>
          </div>
          <div class="list-all">
            <div class="list-item"  @click="title()" >
              <i class="song-index icon-playdetail"></i>
              <div class="item-title">
                <div class="name">
                  <p>全部播放<span>(共76首)</span></p>
                </div>
                <i class="icon-list-music" @click.stop="icon()"></i>
              </div>
            </div>
          </div>
          <song-list v-for="(item,index) in songAll" :key="index" :index="index" :item="item"></song-list>
        </li>
      </ul>
    </v-scroll>
  </div>
</template>

<script type="text/ecmascript-6">
  import Scroll from '@/components/refresh/Refresh';
  import songListHeader from '@/components/header/playListHeader'
  import songLis from '@/components/subassembly/songList'
  import axios from 'axios';
  export default {
    name: "",
    data() {
      return {
        box:'',
        backgroundUrl:'',
        headDom:'',
        songListIntro:{},
        songAll:[]
      }
    },
    methods:{
      getData(){
        axios.get(this.base.conf.http.url + '/playlist/detail?id='+ this.$route.query.uid
        ).then((response) => {
          if(response.data.code === 200) {
            // console.log(response.data);

            this.backgroundUrl = response.data.result.coverImgUrl
            this.songListIntro = {
              coverImgUrl:response.data.result.coverImgUrl,
              id:response.data.result.id,  // 歌单ID
              name:response.data.result.name,
              userId:response.data.result.userId,
            };

            // console.log(this.songListIntro);return
            for (let i = 0; i < response.data.result.tracks.length; i++) {

              let list = response.data.result.tracks[i];
              this.songAll[i]= {

                album: {
                  0: list.album.artists, // 艺术家信息
                  company: list.album.company, // 发行商名称
                  name: list.album.name,   //专辑名称
                  blurPicUrl: list.album.blurPicUrl, // 背景图片
                },
                name: list.name, // 歌曲名称
                id: list.id, // 发行商Id
                Music: list.lMusic // bitrate:96000,dfsId:0,extension:"mp3",id:10214530,name: "西海情歌",playTime: 343536,size: 4143717,sr:44100,volumeDelta: -0.000265076
              };
            }
          }
        }).catch((error) => {
          console.log(error);
        });
      }

    },
    computed:{
    },
    watch:{
      backgroundUrl:function () {
        this.headDom.style.backgroundImage = `url(${this.backgroundUrl})`
        this.headDom.style.backgroundSize = `100000%`
        this.headDom.style.backgroundPosition = `center center`
        this.headDom.style.opacity = 0;
      }
    },
    created(){
      this.getData();
    },
    mounted(){
      //处理 头部背景
      this.headDom = this.$el.querySelector('.list-header'); //储存header DOM 节点
      this.box = this.$el.querySelector('.yo-scroll'); // 获得到滑动块
      this.box.addEventListener('scroll', () => {
        if(this.box.scrollTop < 2000){
          this.headDom.style.opacity = this.box.scrollTop / 140;
        }
      });
    },
    components: {
      'v-scroll': Scroll,
      songListHeader: songListHeader,
      songList: songLis,
    }
  }
</script>

<style lang="scss" scoped>
  @import "../../style/font-icon/style.css";
  @import '../../style/mixin.scss';
  li{
    padding-top: 100px;
  }
  .par-box{
    @include wh(100%,290px);
    position: relative;
  }
  .list-intro {
    @include wh(100%,290px);
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: 10;
    color: rgb(255,255,255);
  }
  .background-img {
    position: absolute;
    z-index: 0;
    height: 390px;
    width: 100%;
    top: -200px;
    padding-top: 100px;

  }
  .list-intro .b-name {
    @include fj(flex-start, flex-start);
  }
  .list-img {
    width: 250px;
    padding-left: 50px;
    padding-right: 40px;
  }
  .about {
    padding-top: 20px;
  }
  .about p:first-child {
    font-size: 34px;
    line-height: 45px;
    height: 90px;
    overflow: hidden;

  }
  ._username {
    @include fj(start, center);
    padding-top: 20px;
    padding-right: 20px;
  }
  .user-img {
    width: 65px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 20px;
  }
  ._username p {
    font-size: 22px;
    width: 100%;
    max-height: 66px;
    overflow: hidden;
    line-height: 33px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  /* button list */
  .b-button{
    @include wh(100%,128px);
    @include fj(space-around,flex-end)
  }
  .b-button div{
    @include wh(80px,70%);
    text-align: center;
  }
  .b-button i {
    font-size: 40px;
  }
  .b-button p {
    font-size: 24px;
  }
  /* 全部播放 栏*/
  .list-all{
    background-color:rgb(243, 244, 246);
  }
  .list-item{
    @include fj(space-between,center);
    @include wh(100%,104px);

    z-index: 9;
  }
  .list-item .song-index{
    font-size: 30px;
    color: rgb(145,146,147);
    padding-left: 10px;
    padding-right: 10px;
    @include wh(102px,102px);
    @include fj(center,center);
  }
  .list-item  .icon-playdetail{
    font-size: 40px;
    font-weight: 500;
    color: rgb(34,34,34);
  }
  .item-title{
    @include fj(space-between,center);
    @include wh(100%,102px);
    border-bottom: 2px solid  rgb(231, 233, 233);
  }
  .item-title p:first-child{
    @include wh(100%,36px);
    overflow: hidden;
    font-size: 28px;
    color: rgb(48,49,49);
    font-family: Tahoma;
    font-weight: 500;
    padding-top: 6px;
    margin-bottom: 10px;
  }
  .item-title .name p {
    @include fj(flex-start,center);
  }
  .item-title .name span{
    font-size: 22px;
    color: rgb(145,146,147);
  }
  .icon-list-music{
    font-size: 30px;
    @include wh(88px,inherit);
    @include fj(center,center);
    padding-right: 8px;
    color: rgb(34,34,34);
  }

</style>
